[% setvar title Alternate Syntax for variable names %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Alternate Syntax for variable names</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: David Corbin &lt;<a href='mailto:dcorbin@machturtle.com'>dcorbin@machturtle.com</a>&gt;
  Date: 20 Aug 2000
  Last Modified: 28 Aug 2000
  Mailing List: <a href='mailto:perl6-language@perl.org'>perl6-language@perl.org</a>
  Number: 133
  Version: 2
  Status: Developing</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>Many new users are confused by the use of $@% to represent context,
when it is also used to declare variables.  This is a syntactic change
that introduces a bit more logic to the context/type confusion.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>Context is an essential part of Perl.  When evaluating a symbolic
expression, $, @ and % are used to indicate the context of the
expression.  However, when variables are declared (using local, my, or
simply implicitly as an lvalue) these same symbols are used.  <code>my
@array; my %hash; $var=1</code>  To many people, most notably programmers new
to Perl, the $@% is mistakenly believed to be part of the variable
name.  This leads to such erroneous attempts to use them as
<code>@array[0]</code>, and <code>@%hash{key}</code>.</p>
<p>Consider the following syntax:</p>
<pre> my var; 	# declaring a scalar
 my array[]; # declaring an array
 my hash{};	# declaring a hash</pre>
<p>Then, when it is necessary to distinguish context explicitly (it often
is not), you can use $@% as before.  Consider:</p>
<pre> count = array;		 # scalar context because of assignment to scalar.
 alt_array[] = array; # list context 

 value = hash{key};   #

 print $array,&quot; &quot;,@array #Context must be clearly designated.</pre>
<p>I'm not the linguist that Mr. Wall is, but it strikes me that context
should be derrived automatically as much as possible.</p>
<p>An slightly different alternative would be that arrays and hashes are
always referred to with their trailing indicator ([] or {}). So, from
the example above, you'd have</p>
<pre> count=array[];
 alt_array[] = array[];</pre>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>Unknown.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>RFC 9: Highlander Variable Types</p>
<p>RFC 109: Less linenoise - let's get rid of @%</p>
</div>
